import request from '@/utils/request'
const API_PREFIX = '/api/v1/user'

import type { User } from './types.ts'
import { Page } from '@/api/types.ts'

/**
 * 用户列表分页
 */
export const getUserList = (params: User.Query) => {
    return request.get<Page<User.Row>>(`${API_PREFIX}/page`, { params })
}

/**
 *  新增用户
 * @param params
 * @returns
 */
export const saveUser = (params: User.Form) => {
    return request.post(`${API_PREFIX}`, params)
}

/**
 *  修改用户信息
 * @param params
 * @returns
 */
export const updateUser = (params: User.Form) => {
    return request.put(`${API_PREFIX}/${params.id}`, params)
}

/**
 *  获取用户表单详情
 * @param id
 * @returns
 */
export const getUserDetail = (id: number) => {
    return request.get<User.Form>(`${API_PREFIX}/${id}/form`)
}

/**
 *  删除用户
 * @param ids 用户ID，多个以英文逗号(,)分割
 * @returns
 */
export const deleteUser = (ids: string) => {
    return request.delete(`${API_PREFIX}/${ids}`)
}

/**
 * 修改用户密码
 * @param params
 * @returns
 */
export const updatePassword = (params: User.Password) => {
    return request.patch(`${API_PREFIX}/${params.userId}/password`, params)
}

/**
 *  修改用户状态
 * @param params
 * @returns
 */
export const updateUserStatus = (params: User.Status) => {
    return request.patch(`${API_PREFIX}/${params.userId}/password`, params)
}

export const getUserInfo = () => {}

export const getCurrentUserInfo = () => {}

export const downloadTemplate = () => {}

export const importUser = () => {}

export const exportUser = () => {}

export const registerUser = () => {}
